package com.googlecode.gwtbb.client.shared.entity.picture;

import com.googlecode.gwtbb.client.shared.entity.IndexedManyToMany;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Dec 23, 2008
 */
public abstract class PictureRelationImpl implements IndexedManyToMany, Serializable {
	// don't have to use this to restrict num pics
	public static final int MAX_NUM_PICTURES = 8;
	public static final String PICTURE_ID = Picture.PICTURE_ID;
	// if any of these properties are different, then it's time to do an update
	public static final List<String> UPDATE_PROPERTIES = Collections.unmodifiableList(Arrays.asList(
		INDEX
	));

	protected Long pictureId;
	protected int index;
	protected Date snapDate;

	public PictureRelationImpl() {
	}

	public PictureRelationImpl(Long pictureId, int index, Date snapDate) {
		this.pictureId = pictureId;
		this.index = index;
		this.snapDate = snapDate;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public Long getPictureId() {
		return pictureId;
	}

	public void setPictureId(Long pictureId) {
		this.pictureId = pictureId;
	}

	public Date getSnapDate() {
		return snapDate;
	}

	public void setSnapDate(Date snapDate) {
		this.snapDate = snapDate;
	}

	public Long getRightId() {
		return pictureId;
	}

	public boolean isDeleted() {
		return index < 0;
	}

	public void setRightId(Long rightId) {
		this.pictureId = rightId;
	}
}
